/**
 * Copyright (C) 2016 Eshore Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.eshore.thrpc.test.demo.api;

import com.eshore.thrpc.config.ClientConfig;
import com.eshore.thrpc.test.gen.EchoService.Iface;

/**
 * The demo of client by api.
 * <p>
 * 
 * @author : zhouzhixiang
 * @date : 2015-9-1
 */
public class ApiClientDemo {
    public static void main(String[] args) {

        String iface = Iface.class.getName();
        ClientConfig<Iface> clientConfig = new ClientConfig<Iface>();
        clientConfig.setService("com.bfd.harpc.demo$EchoService");
        
        
        
        clientConfig.setIface(iface);
        clientConfig.setAddress("127.0.0.1:19090");

        clientConfig.setNonBlock(false);
        
        
        try {
            Iface echoService =  clientConfig.createProxy();
            long start = System.currentTimeMillis();
            for (int i = 0; i < 10; i++) {
                System.out.println(i+"  "+echoService.echo("world!"+i) + echoService.sayHello(" world "+i));
//                Thread.sleep(100);
            }
            System.out.println(System.currentTimeMillis()-start);
            clientConfig.destory();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
